package com.buyhouse.zhaimao.fragment;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.view.View;
import android.widget.TextView;

import com.buyhouse.zhaimao.BaseFragment;
import com.buyhouse.zhaimao.R;
import com.buyhouse.zhaimao.util.DebugLog;
import com.buyhouse.zhaimao.view.ButtonMenu;
import com.buyhouse.zhaimao.view.CircleImageView;

/**
 * 个人中心
 * 
 * @author zhouby
 *
 */
public class PersonalCenterFragment extends BaseFragment {

	/**头像**/
	private CircleImageView mCircleHeader;
	/**称呼**/
	private TextView mName;
	/**手机号是否绑定**/
	private TextView mBindPhone;
	/**个人收藏**/
	private ButtonMenu mBMfavorite;
	/**评价管理**/
	private ButtonMenu mBMevaluate;
	/**投诉、建议**/
	private ButtonMenu mBMcomplain;
	/**微信**/
	private ButtonMenu mBMweiChat;	
	/**微博**/
	private ButtonMenu mBMweiBo;
		
	@Override
	protected int getContentView() {
		return R.layout.fragment_personalcenter;
	}

	@Override
	protected void initFragment() {
		initUI();
	}
	
	private void initUI(){
		mCircleHeader = (CircleImageView) findViewById(R.id.circleHeader);
		mName = (TextView) findViewById(R.id.name);
		mBindPhone = (TextView) findViewById(R.id.phone_bind);
		mBMfavorite = (ButtonMenu) findViewById(R.id.menu_favorite);
		mBMevaluate=(ButtonMenu) findViewById(R.id.menu_evaluate);
		mBMcomplain=(ButtonMenu) findViewById(R.id.menu_complain);
		mBMweiChat=(ButtonMenu) findViewById(R.id.menu_weiChat);
		mBMweiBo=(ButtonMenu) findViewById(R.id.menu_weiBo);
		initData();
	}
	
	private void initData(){
		mBMfavorite.setTextLeft(getResources().getString(R.string.favorite));
		mBMfavorite.setImageLeft(R.drawable.favorite);
		mBMevaluate.setTextLeft(getResources().getString(R.string.evaluate));
		mBMevaluate.setImageLeft(R.drawable.evaluate);
		mBMcomplain.setTextLeft(getResources().getString(R.string.complain));
		mBMcomplain.setImageLeft(R.drawable.complain);
		mBMweiChat.setTextLeft(getResources().getString(R.string.weiChat));
		mBMweiChat.setImageLeft(R.drawable.weichat01);
		mBMweiChat.setColorLeft(getResources().getColor(R.color.green));
		mBMweiChat.setTextRightTwo("未绑定");
		mBMweiChat.setColorRightTwo(getResources().getColor(R.color.blue));
		mBMweiBo.setTextLeft(getResources().getString(R.string.weiBo));
		mBMweiBo.setImageLeft(R.drawable.weibo01);
		
		mBMfavorite.setOnClickListener(this);
		mBMevaluate.setOnClickListener(this);
		mBMcomplain.setOnClickListener(this);
		mBMweiChat.setOnClickListener(this);
		mBMweiBo.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		
		FragmentManager fragmentManager = getFragmentManager();
		FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
		Fragment fragment=null;
		beginTransaction.hide(this);
		switch (v.getId()) {
		case R.id.menu_favorite://个人收藏
			
			fragment=new EvaluateFragment();
			
			break;
		case R.id.menu_evaluate://评价管理
			
			break;
		case R.id.menu_complain://投诉建议
	
			break;
		case R.id.menu_weiChat://微信
	
			break;
		case R.id.menu_weiBo://微博
	
			break;

		default:
			break;
		}
	
		if(null!=fragment){
			beginTransaction.replace(R.id.content,fragment);
			beginTransaction.addToBackStack(null);
			beginTransaction.commit();	
		}else{
			DebugLog.e("Error:fragment is null");
		}				
	}
		
}
